Passed
Pull Request — master (#165)
by Mathieu
03:12 queued 01:18
created

InvoiceItem.getQuantity   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
2
import { Invoice } from './Invoice.entity';
3
4
@Entity()
5
export class InvoiceItem {
6
  @PrimaryGeneratedColumn('uuid')
7
  private id: string;
8
9
  @Column({type: 'varchar', nullable: false})
10
  private title: string;
11
12
  @Column({type: 'integer', nullable: false, comment: 'Stored in minutes'})
13
  private timeSpent: number;
14
15
  @Column({type: 'integer', nullable: false})
16
  private amount: number;
17
18
  @Column({type: 'integer', nullable: true, default: 0})
19
  private discount: number;
20
21
  @ManyToOne(
22
    type => Invoice,
23
    invoice => invoice.items,
24
    {nullable: false, onDelete: 'CASCADE'}
25
  )
26
  invoice: Invoice;
27
28
  constructor(
29
    invoice: Invoice,
30
    title: string,
31
    timeSpent: number,
32
    amount: number,
33
    discount?: number
34
  ) {
35
    this.invoice = invoice;
36
    this.title = title;
37
    this.timeSpent = timeSpent;
38
    this.amount = amount;
39
    this.discount = discount;
40
  }
41
42
  public getId(): string {
43
    return this.id;
44
  }
45
46
  public getTitle(): string {
47
    return this.title;
48
  }
49
50
  public getAmount(): number {
51
    return this.amount;
52
  }
53
54
  public getDiscount(): number {
55
    return this.discount;
56
  }
57
58
  public getTimeSpent(): number {
59
    return this.timeSpent;
60
  }
61
62
  public getInvoice(): Invoice {
63
    return this.invoice;
64
  }
65
}
66